package news.paper.tintuc.tinnong.docbao.doctin.adapter;

import news.paper.tintuc.tinnong.docbao.doctin.util.Constrant;
import news.paper.tintuc.tinnong.docbao.doctin.views.SampleItem;
import news.paper.tintuc.tinnong.docbao.doctin.R;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MenuAdapter extends ArrayAdapter<SampleItem> {
	private Context context;

	public MenuAdapter(Context context_) {
		super(context_, 0);
		context = context_;
	}

	public View getView(int position, View contentView, ViewGroup parentView) {
		if (contentView == null) {
			contentView = LayoutInflater.from(getContext()).inflate(
					R.layout.menu_item, null);
		}
		TextView textView = (TextView) contentView
				.findViewById(R.id.menu_item_textview);
		TextView text = (TextView) contentView
				.findViewById(R.id.menu_item_text);
		text.setText(getItem(position).menuText);
		try {
			if (Constrant.selectedPosition == position) {
				contentView.setBackgroundColor(context.getResources().getColor(
						R.color.sm_menulist_selected_bg));
				text.setTextColor(Color.parseColor("#ffffff"));
				textView.setBackgroundColor(Color.parseColor("#00b0ff"));
			} else {
				contentView.setBackgroundColor(context.getResources().getColor(
						R.color.sm_menulist_unselect_bg));
				text.setTextColor(Color.parseColor("#aaaaaa"));
				textView.setBackgroundResource(R.drawable.null2);
			}
		} catch (Exception e) {
		}
		return contentView;
	}
}